id: task-41 title: 'CLI: Migrate terminal UI to bblessed' status: Done assignee:
- Claude created_date: '2025-06-11' labels:
- cli dependencies: []
Description
Migrate all CLI interfaces to bblessed for a consistent terminal experience.
Acceptance Criteria
- [x] Init wizard uses bblessed forms and lists
- [x] Task view uses bblessed components
- [x] Doc view uses bblessed components
- [x] Board view rendered with bblessed
- [x] Remove prompts-based UI code
- [x] Works on Node and Bun
Implementation Notes
Successfully migrated all terminal UI elements to use the bblessed library from GitHub (context-labs/bblessed), which is a Bun-optimized fork of blessed. This migration eliminated the need for the Windows terminfo patch script that was previously required.
Key Design Decisions:
-
Dynamic Loading with Runtime Detection:
- Blessed is loaded via dynamic imports in
loadBlessed()function - Checks
output.isTTYbefore attempting to load to avoid issues in non-interactive environments - Returns
nullon load failure, enabling seamless fallback behavior
- Blessed is loaded via dynamic imports in
-
Graceful Fallback Strategy:
promptText(): Falls back to readline'screateInterfacefor basic text inputmultiSelect(): Returns empty array when blessed unavailable (non-interactive default)scrollableViewer(): Falls back to simpleconsole.logoutput- Ensures CI/CD pipelines and non-TTY environments continue to work
-
Type Safety Without Hard Dependencies:
- Created
src/types/blessed.d.tswith intentionalanytype to allow optional runtime loading - Used
@ts-ignorecomment for dynamic import to prevent TypeScript compilation errors - This approach keeps blessed as a truly optional dependency
- Created
-
Modular TUI Architecture:
- Centralized all TUI logic in
src/ui/tui.tsfor consistency and maintainability - Each function is self-contained with its own fallback logic
- Created separate
src/ui/board.tsfor board-specific rendering logic
- Centralized all TUI logic in
Implementation Details:
File Structure Changes:
- Created
src/ui/tui.ts- Core TUI wrapper functions - Created
src/ui/board.ts- Board-specific TUI rendering - Created
src/types/blessed.d.ts- TypeScript declarations - Modified
src/cli.ts- Integrated TUI functions and added --tui flags
Command Modifications:
-
Init Command:
- Replaced readline prompts with
promptText()for project/reporter name - Replaced basic prompt with
multiSelect()for agent file selection - Removed dependency on
promptspackage entirely
- Replaced readline prompts with
-
View Commands (task/doc/board):
- Added
--tuioption to all view commands - When flag is present, content is displayed in scrollable blessed box
- Maintains original output format when flag is absent
- Added
Package Updates:
- Removed:
promptspackage (no longer needed) - Added:
blessedfromgithub:context-labs/bblessed(Bun-optimized fork) - Removed:
scripts/patch-blessed.js(no longer needed with bblessed) - Removed:
resources/terminfo/directory (bundled terminfo no longer required) - Updated:
bun.lockandpackage.jsonaccordingly
Technical Implementation:
Blessed Widget Configuration:
- Text input: Centered form with bordered textbox, handles Enter/Escape keys
- Multi-select: List widget with checkbox-style indicators, Space toggles, Enter confirms
- Scrollable viewer: Full-screen box with vi-style navigation (j/k, arrows), q/Escape to exit
- All widgets support mouse interaction where available
Error Handling:
- Try-catch blocks around dynamic imports prevent crashes
- Fallback mechanisms activate automatically on any failure
- No error messages shown to users - seamless degradation
Testing and Compatibility:
- All 140 tests pass without modification
- Tests run successfully without blessed installed (using fallbacks)
- Verified compatibility with both Node.js and Bun runtimes
- No breaking changes to existing CLI behavior